<?php
namespace app\index\controller;
use think\Controller;
use think\Session;
class Wechatpush extends Controller
{

    public function getData(){
		Vendor('phpqrcode');
		$result = Session::get('equnique');
		if($result){
			$cip = $this->getIP();
			// $url = 'http://'.$cip.'/subaoViewapp/#/home/'.$result;
			$url = 'http://47.92.216.173:8080/#/home/'.$result;
			// $url = 'http://'.$cip.':8080'.'/#/home/'.$result;
			//response($enc=\QRcode::png($url,false,'L', 5, 2));
			return $url;
			// return response($enc=\QRcode::png($url,false,'L', 5, 2), 200)->contentType("image/png");
		}else {
			echo '未能获取所发布的地震,推送失败!';
		}
	}


	protected function getIP(){
	    $preg = "/\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\Z/";
	//获取操作系统为win2000/xp、win7的本机IP真实地址
	    exec("ipconfig", $out, $stats);
	    if (!empty($out)) {
	        foreach ($out AS $row) {
	            if (strstr($row, "IP") && strstr($row, ":") && !strstr($row, "IPv6")) {
	                $tmpIp = explode(":", $row);
	                if (preg_match($preg, trim($tmpIp[1]))) {
	                    return trim($tmpIp[1]);
	                }
	            }
	        }
	    }
	}


}